package ua.com.fesvlast.hotel.controller;

import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;

import ua.com.fesvlast.hotel.model.commands.AcceptOrderCommand;
import ua.com.fesvlast.hotel.model.commands.ChosenRoomCommand;
import ua.com.fesvlast.hotel.model.commands.ForwardContact;
import ua.com.fesvlast.hotel.model.commands.MakeOrderCommand;
import ua.com.fesvlast.hotel.model.commands.ForwardOrder;
import ua.com.fesvlast.hotel.model.commands.ICommand;
import ua.com.fesvlast.hotel.model.commands.LogOutCommand;
import ua.com.fesvlast.hotel.model.commands.LoginCommand;
import ua.com.fesvlast.hotel.model.commands.NoCommand;
import ua.com.fesvlast.hotel.model.commands.ProcessAdminOrdersCommand;
import ua.com.fesvlast.hotel.model.commands.RegistrationCommand;
import ua.com.fesvlast.hotel.model.commands.PicturesCommand;
import ua.com.fesvlast.hotel.model.commands.SendMessageCommand;

public class RequestHelper {
	
	private static RequestHelper instance =null;
	
	HashMap<String, ICommand> commands=new HashMap<String, ICommand>();
	
	private RequestHelper(){
		commands.put("login", new LoginCommand());
		commands.put("registration", new RegistrationCommand());
		commands.put("pictures", new PicturesCommand());
		commands.put("chosenRoom", new ChosenRoomCommand());
		commands.put("forwardOrder", new ForwardOrder());
		commands.put("logout", new LogOutCommand());
		commands.put("adminOrders", new ProcessAdminOrdersCommand()); //look all open orders
		commands.put("createBill", new MakeOrderCommand());
		commands.put("forwardContact", new ForwardContact());
		commands.put("sendMessage", new SendMessageCommand() );
		
		
		commands.put("acceptOrders", new AcceptOrderCommand());
	}

	public  ICommand getCommand(HttpServletRequest request) {
		
		String action =request.getParameter("command");
		
		ICommand command =commands.get(action);
		
		if(command ==null){
			command=new NoCommand();
		}
		return command;
	}
	
	public static RequestHelper getInstance(){
		if(instance ==null){
			instance =new RequestHelper();
		}
		return instance;
	}

}
